<?php

m2import("phpinchains/util/db/DbEntityBase.php");

class phpinchains_util_db_SequenceEntity extends phpinchains_util_db_DbEntityBase {

    function phpinchains_util_db_SequenceEntity($table, $actionform, phpinchains_util_db_Preprocessor $preprocessor = null, phpinchains_util_db_Postprocessor $postprocessor = null)
    {
        $af = new phpinchains_ActionForm();
        $this->table = $table;
        $this->fields = array(
            array('id', 'int')
        );
        $this->defaultvalues = array (
        );
        $this->index = array (
        );
        $this->blobs = array (
        );
        $this->foreignKeys = array(

        );
        
        parent::phpinchains_util_db_DbEntityBase($af, $preprocessor, $postprocessor);
    }

    function create ($showquery = false) {
        $query = "insert into ".$this->table." ";
        $fieldStr = '';
        $valueStr = '';
        $this->con->query($query.'(id) values (\'\');', $showquery);
        $id = $this->con->insert_id();
        return $id;
    }

    function getMax () {
        $sth = $this->con->query('select max(id) from '.$this->table.';');
        if (is_object($sth)) {
            $rows = $sth->fetch_rows();
            return $rows[0][0];
        }
        return null;
    }

}


?>